Skip to content

[bugfix] fix tie_word_embeddings#150

Merged
Jintao-Huang merged 1 commit into
modelscope:mainfrom
Jintao-Huang:fix_tie_word_embeddings_0717
Jul 17, 2026
Merged

[bugfix] fix tie_word_embeddings#150
Jintao-Huang merged 1 commit into
modelscope:mainfrom
Jintao-Huang:fix_tie_word_embeddings_0717

Conversation

@Jintao-Huang

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the preservation logic for untie_embeddings_and_output_weights in src/mcore_bridge/config/parser.py. The reviewer points out that removing this logic entirely can cause issues when hf_config.name_or_path is not set, as sub-config defaults might overwrite parent config settings. They suggest a more refined preservation logic that only restores the setting if it was explicitly set to True in the parent config.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 109 to 111
for key in ['text_config', 'llm_config', 'thinker_config']:
if hasattr(config, key):
megatron_config.update(_convert_config(getattr(config, key), _internal_call=True))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Removing the preservation of untie_embeddings_and_output_weights entirely can lead to issues when hf_config.name_or_path is not set (e.g., during programmatic initialization or testing). In such cases, the sub-config's default tie_word_embeddings = True (which maps to untie_embeddings_and_output_weights = False) will overwrite the parent config's explicit or class-default tie_word_embeddings = False (which maps to untie_embeddings_and_output_weights = True).

Instead of removing the preservation logic completely, we can make it smarter: only restore untie_embeddings_and_output_weights if the parent config had it set to True (untied). This prevents the sub-config's default False (tied) from overwriting the parent's explicit True (untied), while still allowing a sub-config's explicit True (untied) to override the parent's default False (tied).

    untie_embeddings_and_output_weights = megatron_config.get('untie_embeddings_and_output_weights')
    for key in ['text_config', 'llm_config', 'thinker_config']:
        if hasattr(config, key):
            megatron_config.update(_convert_config(getattr(config, key), _internal_call=True))
    if untie_embeddings_and_output_weights is True:
        megatron_config['untie_embeddings_and_output_weights'] = untie_embeddings_and_output_weights

@Jintao-Huang
Jintao-Huang merged commit 3539f21 into modelscope:main Jul 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant